home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / os2 / remin301.zip / REMIN300.ZIP / KALL < prev    next >
Text File  |  1992-11-10  |  892b  |  41 lines

  1. #!/bin/sh
  2. #
  3. # kall - kill all processes belonging to this user that match
  4. #           specified string.
  5.  
  6. signal=`echo $1 | grep '^\-.*'`
  7. me=`basename $0`
  8.  
  9. if [ "$signal" != "" ]; then
  10.     shift
  11. else
  12.     signal="-TERM"
  13. fi
  14.  
  15. if [ "$1" = "" ]; then
  16.     echo "usage: $me [-signal] string [string...]"
  17.     echo "       kills all of your processes where command name matches"
  18.     echo "       any of the given strings."
  19.     exit
  20. fi
  21.  
  22. msg="0"
  23.  
  24. while [ "$1" != "" ]; do
  25.  
  26. # NOTE:  You may have to modify the next line, since PS is non-portable.
  27. # The 'awk' command picks out the process IDs to pass them on to kill.
  28.     rprocs=`ps cx | awk '{if(prog == $NF) print $1}' prog=$1 -`
  29.     if [ "$rprocs" != "" ]; then
  30.         msg="1"
  31.         echo -n "${me}: Sending $signal signal to $1 process(es)"
  32.         echo '...'
  33.         kill $signal $rprocs
  34.     fi
  35.     shift
  36. done
  37.  
  38. if [ $msg = "1" ]; then
  39.     echo "${me}: Done."
  40. fi
  41.